/*----------------------饼状图-----------------------*/
//环形图
(function(){
var pie1 = echarts.init(document.getElementById("pie1"));

option = {
	
	title : {
		text: "工单情况",
		x: 'center'
	},
	
    tooltip: {
        trigger: 'item',
        formatter: "{a} <br/>{b}: {c} ({d}%)"
    },
    legend: {
        orient: 'vertical',
        x: 'left',
        data:['已完成工单','未完成工单']
    },
    series: [
        {
            name:'访问来源',
            type:'pie',
            radius: ['50%', '70%'],
            avoidLabelOverlap: false,
            label: {
                normal: {
                    show: false,
                    position: 'center'
                },
                emphasis: {
                    show: true,
                    textStyle: {
                        fontSize: '30',
                        fontWeight: 'bold'
                    }
                }
            },
            labelLine: {
                normal: {
                    show: false
                }
            },
            data:[
                {value:335, name:'已完成工单'},
                {value:310, name:'未完成工单'},
            ]
        }
    ]
};

pie1.setOption(option);

$.ajax({
	type:"post",
	url : "Job/countjoball",//路径 
	contentType : "application/json;charset=UTF-8",
    dataType:"Json",
    async:true,
    success : function(res){
    	console.log(res) 
    	if(res.info == "success"){
    		var info =res.object;
    		var obj = [{value: info.doingcount, name: "未完成工单"},{value: info.finishcount, name: "已完成工单"}]
    		option.series[0].data = obj;
    		pie1.setOption(option);
    		console.log(res.info) 
    	}
    }
})



var pie2 = echarts.init(document.getElementById("pie2"));

$.ajax({
	type:"post",
	url : "Job/countall",//路径 
	contentType : "application/json;charset=UTF-8",
    dataType:"Json",
    async:true,
    success : function(res){
    	console.log(res) 
    	if(res.info == "success"){
    		var info =res.object;
    		var obj = [{value: info.badcount, name: "差评"},{value: info.goodcount, name: "好评"},{value: info.mediumcount, name: "中评"}]
    		option2.series[0].data = obj;
    		pie2.setOption(option2);
    		console.log(res.info) 
    	}
    }
})

option2 = {
	
		title : {
			text: "评价情况",
			x: 'center'
		},
		
	    tooltip: {
	        trigger: 'item',
	        formatter: "{a} <br/>{b}: {c} ({d}%)"
	    },
	    legend: {
	        orient: 'vertical',
	        x: 'left',
	        data:['好评','中评','差评']
	    },
	    series: [
	        {
	            name:'访问来源',
	            type:'pie',
	            radius: ['50%', '70%'],
	            avoidLabelOverlap: false,
	            label: {
	                normal: {
	                    show: false,
	                    position: 'center'
	                },
	                emphasis: {
	                    show: true,
	                    textStyle: {
	                        fontSize: '30',
	                        fontWeight: 'bold'
	                    }
	                }
	            },
	            labelLine: {
	                normal: {
	                    show: false
	                }
	            },
	            data:[
	                {value:335, name:'好评'},
	                {value:310, name:'中评'},
	                {value:1, name:'差评'}
	            ]
        }
    ]
};
pie2.setOption(option2);


})();
